package service;

import java.util.List;
import java.util.Map;

import dao.BookDao;
import entity.Book;

public class BookService {
	/**
	 * 查询编辑推荐图书
	 * 暂定为fixed_price和dang_price相差最大的两本书
	 * @return
	 * @throws Exception 
	 */
	public List<Map<String, Object>> queryRecommendBooks() throws Exception{
		return new BookDao().queryRecommendBooks();
	}
	
	/**
	 * 热销图书定为最便宜的两本图书
	 * @return
	 * @throws Exception
	 */
	public List<Map<String, Object>> queryHotBooks() throws Exception{
		return new BookDao().queryHotBooks();
	}
	
	/**
	 * 新书热卖定为最晚添加的两本图书
	 * @return
	 * @throws Exception
	 */
	public List<Map<String, Object>> queryNewBooks() throws Exception{
		return new BookDao().queryNewBooks();
	}
	
	public List<Map<String, Object>> queryBookByCid(Map<String, Object> map) throws Exception{
		map.put("beginningIndex", ((Integer) map.get("page") - 1) * (Integer) map.get("pageSize"));
		return new BookDao().queryBookByCid(map);
	}
	
	public Long queryTotalSizeByCid(Integer cid) throws Exception{
		return new BookDao().queryTotalSizeByCid(cid);
	}
	
	public Book queryBookById(Integer id) throws Exception{
		return new BookDao().queryBookById(id);
	}
}
